const btn = document.querySelector(".space-y-6  button");

btn.addEventListener("click", async e => {
  e.preventDefault();
  const username = document.querySelector("[type=text]").value;
  const password = document.querySelector("[type=password]").value;
  const data = {
    username,
    password,
  };
  const res = await axios({
    method: "post",
    url: "/login",
    data,
  })
  if (res.code == 0) {
    console.log(res.msg);
    localStorage.setItem("token", res.msg.token);
    localStorage.setItem("user_id", res.msg.user_id);
    localStorage.setItem("url", res.msg.avatar_url);
    localStorage.setItem("username", username);
    myAlert(true, "登录成功")
    setTimeout(() => {
      location.href = `../index/index.html`
    }, 1000)
  } else {
    myAlert(false, res.msg)
  }
})